﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Controls_Search : System.Web.UI.UserControl
{
    string sql;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            Areabig();
        }
    }
    public void Areabig()//地区大类
    {
        sql = "select * from Area where oneid<>0 and twoid=0 and threeid=0 order by sort";
        DataTable dt = Class1.ExecSel(sql);
        Ddl_AreaOne.DataSource = dt;
        Ddl_AreaOne.DataTextField = "areaname";
        Ddl_AreaOne.DataValueField = "oneid";
        Ddl_AreaOne.DataBind();
    }
    protected void Ddl_AreaOne_SelectedIndexChanged(object sender, EventArgs e)
    {
        Ddl_AreaTwo.Items.Clear();
        Ddl_AreaTwo.Items.Add(new ListItem("全部", "0"));
        Ddl_AreaThree.Items.Clear();
        Ddl_AreaThree.Items.Add(new ListItem("全部", "0"));

        sql = "select * from Area where twoid<>0 and threeid=0 and oneid=" + Ddl_AreaOne.SelectedValue + " order by sort";
        DataTable dt = Class1.ExecSel(sql);
        Ddl_AreaTwo.DataSource = dt;
        Ddl_AreaTwo.DataTextField = "areaname";
        Ddl_AreaTwo.DataValueField = "twoid";
        Ddl_AreaTwo.DataBind();
    }
    protected void Ddl_AreaTwo_SelectedIndexChanged(object sender, EventArgs e)
    {
        Ddl_AreaThree.Items.Clear();
        Ddl_AreaThree.Items.Add(new ListItem("全部", "0"));

        sql = "select * from Area where threeid<>0 and oneid=" + Ddl_AreaOne.SelectedValue;
        sql += " and twoid=" + Ddl_AreaTwo.SelectedValue + " order by sort";
        DataTable dt = Class1.ExecSel(sql);
        Ddl_AreaThree.DataSource = dt;
        Ddl_AreaThree.DataTextField = "areaname";
        Ddl_AreaThree.DataValueField = "threeid";
        Ddl_AreaThree.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string AreaOne = Ddl_AreaOne.SelectedItem.Text;
        string AreaTwo = Ddl_AreaTwo.SelectedItem.Text;
        string AreaThree = Ddl_AreaThree.SelectedItem.Text;

        string Wtype = DropDownList2.SelectedItem.Text;
        string Wtitle = TextBox1.Text;



        Response.Redirect("wjSearch_K.aspx?AreaOne=" + AreaOne + "&AreaTwo=" + AreaTwo + "&AreaThree=" + AreaThree + "&Wtype=" + Wtype + "&Wtitle=" + Wtitle + "");
        
    }
}
